package com.baobao.web;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;

import org.springframework.test.context.ContextConfiguration;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Unit test for the <code>AskleaveController</code> controller.
 *
 * @see com.baobao.web.AskleaveController
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
		"file:./resources/bb-security-context.xml",
		"file:./resources/bb-service-context.xml",
		"file:./resources/bb-dao-context.xml",
		"file:./resources/bb-web-context.xml" })
public class AskleaveControllerTest {
	/**
	 * The Spring application context.
	 *
	 */
	private ApplicationContext context;

	/**
	 * Test <code>indexAskleave()</code>.
	 */
	@Test
	@SuppressWarnings("unused")
	public void GetindexAskleave() throws Exception {
		MockHttpServletRequest request = getMockHttpServletRequest();
		request.setRequestURI("/indexAskleave");
		MockHttpServletResponse response = getMockHttpServletResponse();

		// Get the singleton controller instance
		AskleaveController controller = (AskleaveController) context.getBean("AskleaveController");

		// TODO Invoke method and Assert return values

	}

	/**
	 * Test <code>selectAskleave()</code>.
	 */
	@Test
	@SuppressWarnings("unused")
	public void GetselectAskleave() throws Exception {
		MockHttpServletRequest request = getMockHttpServletRequest();
		request.setRequestURI("/selectAskleave");
		MockHttpServletResponse response = getMockHttpServletResponse();

		// Get the singleton controller instance
		AskleaveController controller = (AskleaveController) context.getBean("AskleaveController");

		// TODO Invoke method and Assert return values

	}

	/**
	 * Test <code>editAskleave()</code>.
	 */
	@Test
	@SuppressWarnings("unused")
	public void GeteditAskleave() throws Exception {
		MockHttpServletRequest request = getMockHttpServletRequest();
		request.setRequestURI("/editAskleave");
		MockHttpServletResponse response = getMockHttpServletResponse();

		// Get the singleton controller instance
		AskleaveController controller = (AskleaveController) context.getBean("AskleaveController");

		// TODO Invoke method and Assert return values

	}

	/**
	 * Test <code>saveAskleave()</code>.
	 */
	@Test
	@SuppressWarnings("unused")
	public void GetsaveAskleave() throws Exception {
		MockHttpServletRequest request = getMockHttpServletRequest();
		request.setRequestURI("/saveAskleave");
		MockHttpServletResponse response = getMockHttpServletResponse();

		// Get the singleton controller instance
		AskleaveController controller = (AskleaveController) context.getBean("AskleaveController");

		// TODO Invoke method and Assert return values

	}

	/**
	 * Test <code>newAskleave()</code>.
	 */
	@Test
	@SuppressWarnings("unused")
	public void GetnewAskleave() throws Exception {
		MockHttpServletRequest request = getMockHttpServletRequest();
		request.setRequestURI("/newAskleave");
		MockHttpServletResponse response = getMockHttpServletResponse();

		// Get the singleton controller instance
		AskleaveController controller = (AskleaveController) context.getBean("AskleaveController");

		// TODO Invoke method and Assert return values

	}

	/**
	 * Test <code>confirmDeleteAskleave()</code>.
	 */
	@Test
	@SuppressWarnings("unused")
	public void GetconfirmDeleteAskleave() throws Exception {
		MockHttpServletRequest request = getMockHttpServletRequest();
		request.setRequestURI("/confirmDeleteAskleave");
		MockHttpServletResponse response = getMockHttpServletResponse();

		// Get the singleton controller instance
		AskleaveController controller = (AskleaveController) context.getBean("AskleaveController");

		// TODO Invoke method and Assert return values

	}

	/**
	 * Test <code>deleteAskleave()</code>.
	 */
	@Test
	@SuppressWarnings("unused")
	public void GetdeleteAskleave() throws Exception {
		MockHttpServletRequest request = getMockHttpServletRequest();
		request.setRequestURI("/deleteAskleave");
		MockHttpServletResponse response = getMockHttpServletResponse();

		// Get the singleton controller instance
		AskleaveController controller = (AskleaveController) context.getBean("AskleaveController");

		// TODO Invoke method and Assert return values

	}

	/**
	 * Test <code>askleaveControllerbinaryaction()</code>.
	 */
	@Test
	@SuppressWarnings("unused")
	public void GetaskleaveControllerbinaryaction() throws Exception {
		MockHttpServletRequest request = getMockHttpServletRequest();
		request.setRequestURI("/askleaveController/binary.action");
		MockHttpServletResponse response = getMockHttpServletResponse();

		// Get the singleton controller instance
		AskleaveController controller = (AskleaveController) context.getBean("AskleaveController");

		// TODO Invoke method and Assert return values

	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Returns a mock HttpServletRequest object.
	 *
	 */
	private MockHttpServletRequest getMockHttpServletRequest() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
		return request;
	}

	/**
	 * Returns a mock HttpServletResponse object.
	 *
	 */
	private MockHttpServletResponse getMockHttpServletResponse() {
		return new MockHttpServletResponse();
	}
}